package hqb.dev.webdeploy.logic;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

/**
 * logback日志过滤器，仅记录hqb.dev.webdeploy包下的日志，且只输出main线程的日志
 *
 * @author HQB--2024-04-23
 **/
public class RunLogFilter extends Filter<ILoggingEvent> {
    @Override
    public FilterReply decide(ILoggingEvent iLoggingEvent) {
        if (
                iLoggingEvent.getLoggerName().contains("hqb.dev.webdeploy")
                        && !iLoggingEvent.getThreadName().contains("main")
        ) {
            return FilterReply.ACCEPT;
        }
        return FilterReply.DENY;
    }
}
